//----------------------------------*-C++-*----------------------------------//
/*!
 * \file   Cross_Section.i.hh
 * \author Jeremy Roberts
 * \date   Jul 20, 2011
 * \brief  Cross_Section inline member definitions.
 * \note   Copyright (C) 2011 Jeremy Roberts. 
 */
//---------------------------------------------------------------------------//
// $Rev::                                               $:Rev of last commit
// $Author:: j.alyn.roberts@gmail.com                   $:Author of last commit
// $Date::                                              $:Date of last commit
//---------------------------------------------------------------------------//

#ifndef CROSS_SECTION_I_HH_
#define CROSS_SECTION_I_HH_

namespace slabtran
{

// Mutable access of scattering cross section moment in /cm.
inline double& Cross_Section::sigma_s(int g, int g_prime, int l)
{
  Require(g >= 0 && g < d_number_groups);
  Require(g_prime >= d_group_lower_bound[d_adjoint][g]);
  Require(g_prime <= d_group_upper_bound[d_adjoint][g]);
  group_index(g, g_prime);
  return d_S[g][g_prime][l];
}

// Const access of scattering cross section moment in /cm.
inline const double& Cross_Section::sigma_s(int g, int g_prime, int l) const
{
  Require(g >= 0 && g < d_number_groups);
  Require(g_prime >= d_group_lower_bound[d_adjoint][g]);
  Require(g_prime <= d_group_upper_bound[d_adjoint][g]);
  group_index(g, g_prime);
  return d_S[g][g_prime][l];
}

// Mutable access of scattering cross section block
inline std::vector<double>& Cross_Section::sigma_s(int g, int g_prime)
{
  Require(g >= 0 && g < d_number_groups);
  Require(g_prime >= d_group_lower_bound[d_adjoint][g]);
  Require(g_prime <= d_group_upper_bound[d_adjoint][g]);
  group_index(g, g_prime);
  return d_S[g][g_prime];
}

// Const access of scattering cross section block
inline const std::vector<double>& Cross_Section::sigma_s(int g, int g_prime) const
{
  Require(g >= 0 && g < d_number_groups);
  Require(g_prime >= d_group_lower_bound[d_adjoint][g]);
  Require(g_prime <= d_group_upper_bound[d_adjoint][g]);
  group_index(g, g_prime);
  return d_S[g][g_prime];
}

// Lower bound for scattering loop
inline int Cross_Section::group_lower_bound(int g) const
{
  Require(g >= 0 && g < d_number_groups);
  return  d_group_lower_bound[d_adjoint][g];
}

// Upper bound for scattering loop
inline int Cross_Section::group_upper_bound(int g) const
{
  Require(g >= 0 && g < d_number_groups);
  return  d_group_upper_bound[d_adjoint][g];
}

// Correct indices for adjoint calculations (private)
// \todo test me
inline void Cross_Section::group_index(int &g1, int &g2) const
{
  if (d_adjoint)
  {
    int g(g1);
    g1 = g2;
    g2 = g;
  }
}

} // end namespace slabtran

#endif /* CROSS_SECTION_I_HH_ */

//---------------------------------------------------------------------------//
//              end of Cross_Section.i.hh
//---------------------------------------------------------------------------//
